﻿using System;
using System.IO;
using System.ServiceModel;
using bank.DTOs;

namespace OurServices.BankServices
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "FundTransf" in code, svc and config file together.
    public class FundTransf : IFundTransf
    {
        public CustomerDetails GetCustDt()
        {
            // Activator.CreateInstance("");
            CustomerDetails csd = new CustomerDetails();
            csd.CustId = 222;
            csd.Name = "Debasish";
            csd.Address = "23/g g";

            return csd;
        }

        public void SaveCustomer(CustomerDetails csd)
        {
            File.WriteAllText(@"d:\Student\stud2.txt", csd.CustId + " " + csd.Name + " " + csd.Address);
        }

        public bool AddCustomer(Customer customer)
        {
            //save customer to DB
            try
            {
                File.WriteAllText(@"d:\Studentttt\stud.txt", customer.CustId + " " + customer.Name + " " + customer.ContactNo);
                return true;
            }
            catch (Exception ex)
            {
                LowValueException sx = new LowValueException();
                sx.Title = "IO";
                sx.Message = "Error of the service" + ex.Message;
                sx.PosiRemedi = "Write good code....";
                throw new FaultException<LowValueException>(sx, "Testing");
            }

        }
        public Customer GetCustomer(int custId)
        {
            return new Customer();
        }


        #region IFundTransf Members

        public bool Trans(int acNo, int amt)
        {
            var studs = StudentXML.GetStudents();
            //seaqrch the acno
            // trnsf. the amt;
            //if success
            return true;
            //else
            // return false;
        }

        public int ChkBalance(int acNo, int brno)
        {
            // serach the acno and get the balance and return the amt.

            return 450000;
        }

        #endregion
    }
}
